<%@page import="com.cqan.account.entity.Authority.AuthType"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>锐信内容管理系统-修改用户信息</title>
<%@include file="/WEB-INF/pages/common/taglibs.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}resources/css/screen.css" />
<link rel="stylesheet" type="text/css" href="${ctx}resources/css/list.css" />
<script type="text/javascript" src="${ctx}resources/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="${ctx}resources/js/md5-min.js"></script>
</head>
<style>
.sing {
	width: 200px;
	height: 25px;
}
input {
	border:#999 1px solid;
}
</style>
<script type="text/javascript">
$().ready(function() {
	$("#signupForm").validate({
		rules: {
			code: {
				required: true
			},
			name: {
				required: true
			},
			url: {
				required: true
			}
		},
		messages: {
			code: {
				required: "*权限码不能为空！"
			},
			name: {
				required: "*权限名称不能为空！"
			},
			url: {
				required: "*URL不能为空！"
			}
		}
	});
});

function md5(){
	var url = $("#url").val();
	url = $.trim(url);
	if(url.length<=0){
		alert("url 长度不能为空!");
		return ;
	}
	$("#code").val(hex_md5(url));
}
</script>
</head><body>
<div align="center" style="padding-top:20px;">
  <form  id="signupForm" method="post" action="${ctx}auth/save.htm">
    <input type="hidden" value="${auth.id}" name="id">
    <input type="hidden" value="${pageNo}" name="pageNo">
    <table width="95%" cellpadding="0" cellspacing="1" align="center" id="bordertable">
      <tr class="tr0" height="40">
        <td align="right" width="40%"><label>权限名称:</label></td>
        <td align="left" width="60%"><input name="name" value="${auth.name}" class="sing"></td>
      </tr>
      <tr class="tr0" height="40" >
        <td align="right" width="40%"><label>权限码:</label></td>
        <td align="left" width="60%" ><input name="code" value="${auth.code}" class="sing" id="code" readonly="readonly">
          <input type="button" value="获取权限码" onclick="md5()"></td>
      </tr>
      <tr class="tr0" height="40">
        <td align="right" width="40%"><label>上级权限:</label></td>
        <td align="left" width="60%"><select class="sing" name="pid">
            <option value="0" ${auth.parent==null?"selected":""}>顶级权限</option>
            <c:forEach items="${auths}" var="a">
              <option value="${a.id}"  ${auth.parent==null?"":auth.parent.id==a.id?"selected":""}>${a.name}</option>
            </c:forEach>
          </select></td>
      </tr>
      <tr class="tr0" height="40">
        <td align="right" width="40%"><label>权限类型:</label></td>
        <td align="left" width="60%"><select name="authType"  class="sing">
            <%for(AuthType authType: AuthType.values()){ %>
            <option value="<%=authType%>"><%=authType.getLabel() %></option>
            <%} %>
          </select></td>
      </tr>
      <tr class="tr0" height="40" >
        <td align="right" width="40%"><label>状态:</label></td>
        <td align="left" width="60%"><input type="radio"  name="enabled" value="1" ${auth.enabled?"checked":""}/>
          正常&nbsp;&nbsp;
          <input type="radio" value="0" name="enabled" ${auth.enabled?"":"checked"}/>
          禁用</td>
      </tr>
      <tr class="tr0" height="40">
        <td align="right" width="40%"><label>权限地址:</label></td>
        <td align="left" width="60%"><input name="url" id="url" value="${auth.url}" class="sing"></td>
      </tr>
     <tr height="60px;"  class="tr0">
			<td style="padding-right: 20px;text-align: right;"><input class="button" type="submit" value="提交"/></td>
			<td  style="padding-left: 20px;text-align: left;"><input class="button"  type="reset" value="取消" onclick="javascript:history.back();"/></td>
		</tr>
    </table>
  </form>
</div>
</body>
</html>